﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessObjects;
using System.Configuration;

namespace DataAccess
{
    public class HopDongFactory
    {
        private static readonly string dataProvider = ConfigurationManager.AppSettings.Get("DataProvider");
        private static readonly DataFactory factory = DataFactories.GetFactory(dataProvider);

        public static HopDong GetHopDong(int giaTri)
        {
            ThamChieuDuLieu thamChieuDuLieu = factory.ThamChieuDuLieu.GetThamChieuDuLieu(giaTri, typeof(HopDong).ToString());

            if (thamChieuDuLieu.Con.TenKieuDuLieu == typeof(HopDongThinhGiang).ToString())
            {
                return factory.HopDongThinhGiang.GetHopDongThinhGiang(thamChieuDuLieu.GiaTri);
            }
            else if (thamChieuDuLieu.Con.TenKieuDuLieu == typeof(HopDongLamViec).ToString())
            {
                return factory.HopDongLamViec.GetHopDongLamViec(thamChieuDuLieu.GiaTri);
            }
            else if (thamChieuDuLieu.Con.TenKieuDuLieu == typeof(HopDongLaoDong).ToString())
            {
                return factory.HopDongLaoDong.GetHopDongLaoDong(thamChieuDuLieu.GiaTri);
            }
            else if (thamChieuDuLieu.Con.TenKieuDuLieu == typeof(HopDongKhoan).ToString())
            {
                return factory.HopDongKhoan.GetHopDongKhoan(thamChieuDuLieu.GiaTri);
            }
            return null;
        }
    }
}
